<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/22
  Time: 17:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
</head>
<body>
<%
//判断是否有保存的Cookie,如果有，勾选,如果没有，没有勾选
    Cookie[] cookies = request.getCookies();
    if(cookies!=null){
        for(Cookie c:cookies){
            //获取指定的Cookie
            if("username".equals(c.getName())){
                pageContext.setAttribute("username",c.getValue());
            }
            if("password".equals(c.getName())){
                pageContext.setAttribute("password",c.getValue());
            }
        }
    }
%>
<form action="login">
    <table align="center" cellspacing="30px">
        <tr>
            <td>账号:</td>
            <td><input type="text" name="username" value="${username}"/></td>
        </tr>
        <tr>
            <td>密码:</td>
            <td> <input type="password" name="password" value="${password}"/></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="checkbox" value="checkOn" name="save" <c:if test="${!empty username}">checked</c:if> />记住账号和密码
            </td>
        </tr>

        <tr>
            <td colspan="2"><input type="submit" value="登录"/></td>
        </tr>
    </table>
</form>
</body>
</html>
